/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package handlers;

import database.*;
import gui.*;
import java.sql.*;
import java.util.ArrayList;
import model.*;

/**
 *
 * @author Allan
 */
public abstract class LoginHandler
{
    public static ArrayList<Customer> getUserAndCustomer(String bruger, String adgangskode) throws ClassNotFoundException, SQLException
    {
        String uid = "'" + bruger + "'";
        String pwd = "'" + adgangskode + "'";

        Database db = new Database();
        db.connectToDB();

        ResultSet rs = db.query("call checkLogin(" + uid +","+ pwd + ")");
        
        ArrayList<Customer> toReturn = new ArrayList();
        
        if(!rs.last())
        {
            toReturn = null;
        }
        else
        {
            toReturn.add(new Customer(rs.getInt("brugerID"), rs.getString("brugerNavn"), rs.getString("adgangskode"), rs.getInt("kundeID"), rs.getString("firmaNavn")));
        }
        
        return toReturn;
    }
    
}
